.so ../bk-macros
.TH "bk diff" "\*[BKVER]" "22sep1993" "GNU Tools" "GNU Tools"
.SH NAME
bk diff \- find differences between two files
.SH SYNOPSIS
.B bk diff
.[ARG] options
.ARG from-file
.ARG to-file
.SH DESCRIPTION
In the simplest case, 
.B bk diff
compares the contents of the two files
.ARG from-file
and
.ARG to-file .
A file name of
.Q \-
stands for
text read from the standard input.  As a special case,
.Q "bk diff \- \-"
compares a copy of standard input to itself.
If 
.ARG from-file
is a directory and
.ARG to-file
is not,
.B bk diff
compares the file in
.ARG from-file
whose file name is that of
.ARG to-file ,
and vice versa.  The non-directory file must not be
.QR \- .
If both
.ARG from-file
and
.ARG to-file
are directories,
.B bk diff
compares corresponding files in both directories, in
alphabetical order; this comparison is not recursive unless the
.Q \-r
or
.Q \-\-recursive
option is given.
.B bk diff
never
compares the actual contents of a directory as if it were a file.  The
file that is fully specified may not be standard input, because standard
input is nameless and the notion of ``file with the same name'' does not
apply.
.B bk diff
options begin with
.QR \- ,
so normally
.ARG from-file
and
.ARG to-file
may not begin with
.QR \- .
However,
.Q \-\-
as an
argument by itself treats the remaining arguments as file names even if
they begin with
.QR \- .
.SH OPTIONS
Most options have two equivalent names, one of which is a single letter
preceded by
.QR \- ,
and the other of which is a long name preceded by
.QR \-\- .
Multiple single letter options (unless they take an
argument) can be combined into a single command line word:
.Q \-ac
is
equivalent to
.QR "\-a \-c" .
Long named options can be abbreviated to
any unique prefix of their name.
.TP
.OPTreq \- lines
Show
.ARG lines
(an integer) lines of context.  This option does not
specify an output format by itself; it has no effect unless it is
combined with
.Q \-c
or
.QR \-u .
This option is obsolete.  For proper
operation,
.B bk patch
typically needs at least two lines of context.
.TP
.B \-a
Treat all files as text and compare them line-by-line, even if they
do not seem to be text.
.TP
.B \-b
Ignore changes in amount of white space.
.TP
.B \-B
Ignore changes that just insert or delete blank lines.
.TP
.B \-\-brief
Report only whether the files differ, not the details of the
differences.
.TP
.B \-c
Use the context output format.
.TP
.OPTreq "\-C " lines
.br
.ns
.TP
.OPTopt \-\-context "= lines"
Use the context output format, showing
.ARG lines
(an integer) lines of
context, or three if
.ARG lines
is not given.
For proper operation,
.B bk patch
typically needs at least two lines of
context.
.TP
.OPTreq \-\-changed\-group\-format= format
Use
.ARG format
to output a line group containing differing lines from
both files in if-then-else format.
.TP
.B \-d
Change the algorithm to perhaps find a smaller set of changes.  This makes
.B bk diff
slower (sometimes much slower).
.TP
.OPTreq "\-D " name
Make merged if-then-else format output, conditional on the preprocessor
macro
.ARG name .
.TP
.B \-e
.br
.ns
.TP
.B \-\-ed
Make output that is a valid
.BR ed (1)
script.
.TP
.OPTreq \-\-exclude= pattern
When comparing directories, ignore files and subdirectories whose basenames
match
.ARG pattern .
.TP
.OPTreq \-\-exclude\-from= file
When comparing directories, ignore files and subdirectories whose basenames
match any pattern contained in
.ARG file .
.TP
.B \-\-expand\-tabs
Expand tabs to spaces in the output, to preserve the alignment of tabs
in the input files.
.TP
.B \-f
Make output that looks vaguely like an
.BR ed (1)
script but has changes
in the order they appear in the file.
.TP
.OPTreq "\-F " regexp
In context and unified format, for each hunk of differences, show some
of the last preceding line that matches
.ARG regexp .
.TP
.B \-\-forward\-ed
Make output that looks vaguely like an
.BR ed (1)
script but has changes
in the order they appear in the file.
.TP
.B \-h
This option currently has no effect; it is present for \*(UN
compatibility.
.TP
.B \-H
Use heuristics to speed handling of large files that have numerous
scattered small changes.
.TP
.OPTreq \-\-horizon\-lines= lines
Do not discard the last
.ARG lines
lines of the common prefix
and the first
.ARG lines
lines of the common suffix.
.TP
.B \-i
Ignore changes in case; consider upper- and lower-case letters
equivalent.
.TP
.OPTreq "\-I " regexp
Ignore changes that just insert or delete lines that match
.ARG regexp .
.TP
.OPTreq \-\-ifdef= name
Make merged if-then-else format output, conditional on the preprocessor
macro
.ARG name .
.TP
.B \-\-ignore\-all\-space
Ignore white space when comparing lines.
.TP
.B \-\-ignore\-blank\-lines
Ignore changes that just insert or delete blank lines.
.TP
.B \-\-ignore\-case
Ignore changes in case; consider upper- and lower-case to be the same.
.TP
.OPTreq \-\-ignore\-matching\-lines= regexp
Ignore changes that just insert or delete lines that match
.ARG regexp .
.TP
.B \-\-ignore\-space\-change
Ignore changes in amount of white space.
.TP
.B \-\-initial\-tab
Output a tab rather than a space before the text of a line in normal or
context format.  This causes the alignment of tabs in the line to look
normal.
.TP
.B \-l
Pass the output through
.BR pr (1)
to paginate it.
.TP
.OPTreq "\-L " label
.br
.ns
.TP
.OPTreq \-\-label= label
Use
.ARG label
instead of the file name in the context format
and unified format
headers.
.TP
.B \-\-left\-column
Print only the left column of two common lines in side by side format.
.TP
.OPTreq \-\-line\-format= format
Use
.ARG format
to output all input lines in in-then-else format.
.TP
.B \-\-minimal
Change the algorithm to perhaps find a smaller set of changes.  This
makes
.B bk diff
slower (sometimes much slower).
.TP
.B \-n
Output RCS-format diffs; like
.B \-f
except that each command
specifies the number of lines affected.
.TP
.B \-N
.br
.ns
.TP
.B \-\-new\-file
In directory comparison, if a file is found in only one directory,
treat it as present but empty in the other directory.
.TP
.OPTreq \-\-new\-group\-format= format
Use
.ARG format
to output a group of lines taken from just the second
file in if-then-else format.
.TP
.OPTreq \-\-new\-line\-format= format
Use 
.ARG format
to output a line taken from just the second file in
if-then-else format.
.TP
.OPTreq \-\-old\-group\-format= format
Use
.ARG format
to output a group of lines taken from just the first
file in if-then-else format.
.TP
.OPTreq \-\-old\-line\-format= format
Use
.ARG format
to output a line taken from just the first file in
if-then-else format.
.TP
.B \-p
Show which C function each change is in.
.TP
.B \-P
When comparing directories, if a file appears only in the second
directory of the two, treat it as present but empty in the other.
.TP
.B \-\-paginate
Pass the output through
.BR pr (1)
to paginate it.
.TP
.B \-q
Report only whether the files differ, not the details of the
differences.
.TP
.B \-r
When comparing directories, recursively compare any subdirectories
found.
.TP
.B \-\-rcs
Output \*(R-format diffs; like
.B \-f
except that each command
specifies the number of lines affected.
.TP
.B \-\-recursive
When comparing directories, recursively compare any subdirectories
found.
.TP
.B \-\-report\-identical\-files
.br
.ns
.TP
.B \-s
Report when two files are the same.
.TP
.OPTreq "\-S " file
When comparing directories, start with the file
.ARG file .
This is
used for resuming an aborted comparison.
.TP
.OPTreq \-\-from\-file= file
Compare
.ARG file
to all operands.
.ARG file
can be a directory.
.TP
.OPTreq \-\-to\-file= file
Compare all operands to
.ARG file .
.ARG file
can be a directory.
.TP
.B \-\-sdiff\-merge\-assist
Print extra information to help
.BR sdiff (1).
.\" XXX should we document this option?  sdiff(1) doesn't know about bk diff.
.B sdiff
uses this
option when it runs
.BR diff .
This option is not intended for users
to use directly.
.TP
.B \-\-show\-c\-function
Show which C function each change is in.
.TP
.OPTreq \-\-show\-function\-line= regexp
In context and unified format, for each hunk of differences, show some
of the last preceding line that matches
.ARG regexp .
.TP
.B \-\-side\-by\-side
Use the side by side output format.
.TP
.B \-\-speed\-large\-files
Use heuristics to speed handling of large files that have numerous
scattered small changes.
.TP
.ARG \-\-starting\-file= file
When comparing directories, start with the file
.ARG file .
This is
used for resuming an aborted comparison.
.TP
.B \-\-suppress\-common\-lines
Do not print common lines in side by side format.
.TP
.B \-t
Expand tabs to spaces in the output, to preserve the alignment of tabs
in the input files.
.TP
.B \-T
Output a tab rather than a space before the text of a line in normal or
context format.  This causes the alignment of tabs in the line to look
normal.
.TP
.B \-\-text
Treat all files as text and compare them line-by-line, even if they
do not appear to be text.
.TP
.B \-u
Use the unified output format.
.TP
.OPTreq \-\-unchanged\-group\-format= format
Use
.ARG format
to output a group of common lines taken from both files
in if-then-else format.
.TP
.OPTreq \-\-unchanged\-line\-format= format
Use
.ARG format
to output a line common to both files in if-then-else
format.
.TP
.B \-\-unidirectional\-new\-file
When comparing directories, if a file appears only in the second
directory of the two, treat it as present but empty in the other.
.TP
.OPTreq "\-U " lines
.br
.ns
.TP
.OPTreq \-\-unified[= lines ]
Use the unified output format, showing
.ARG lines
(an integer) lines of
context, or three if
.ARG lines
is not given.
For proper operation,
.B bk patch
typically needs at least two lines of
context.
.TP
.B \-v
.br
.ns
.TP
.B \-\-version
Output the version number of
.BR "bk diff" .
.TP
.B \-w
Ignore white space when comparing lines.
.TP
.OPTreq "\-W " columns
.br
.ns
.TP
.OPTreq \-\-width= columns
Use an output width of
.ARG columns
in side by side format.
.TP
.OPTreq "\-x " pattern
When comparing directories, ignore files and subdirectories whose basenames
match
.ARG pattern .
.TP
.OPTreq "\-X " file
When comparing directories, ignore files and subdirectories whose basenames
match any pattern contained in
.ARG file .
.TP
.B \-y
Use the side by side output format.
.\" XXX I get connection refused by ftp.bitkeeper.com
.\".SH SOURCE
.\"The source code for the versions of GNU tools shipped by \*(BM is available at
.\".BR ftp://ftp.bitkeeper.com/gnu .
.SH EXIT STATUS
.B bk diff
returns exit status:
.TP
0
if no differences were found
.tp
1
if some differences were found
.tp
2
if an error occurred
.SH NOTES
.B bk diff
uses the GNU implementation of
.BR diff (1).
.SH SEE ALSO
.SA credits
.SA patch
.BR cmp (1),
.BR comm (1),
.BR diff3 (1),
.BR ed (1),
.BR pr (1),
.BR sdiff (1).
.SH CATEGORY
.B Utility
